using DiLu.Expansion.File.Configs;
using FluentFTP;

namespace DiLu.Expansion.File.Operates.FTP.Configs;

/// <summary>
///     获取FTP文件流配置
/// </summary>
public record GetFtpFileStreamConfig : GetFileStreamConfig
{
    /// <summary>
    ///     获取FTP文件流配置
    /// </summary>
    /// <param name="fileFullPath">文件完整路径</param>
    /// <param name="ftpClient">FTP客户端</param>
    /// <param name="autoCloseFtpClient">
    ///     自动关闭FTP客户端 默认自动关闭客户端连接
    ///     如果为false需要自行调用 CloseFtpClientConnectAsync()方法
    /// </param>
    public GetFtpFileStreamConfig(string fileFullPath, AsyncFtpClient ftpClient, bool autoCloseFtpClient) : base(fileFullPath)
    {
        ArgumentNullException.ThrowIfNull(ftpClient, nameof(ftpClient));
        FtpClient = ftpClient;
        AutoCloseFtpClient = autoCloseFtpClient;
    }

    /// <summary>
    ///     获取FTP文件流配置
    /// </summary>
    /// <param name="rootDirectory">根目录</param>
    /// <param name="fileGroupName">文件分组名称</param>
    /// <param name="fileRelativePath">文件相对路径</param>
    /// <param name="ftpClient">FTP客户端</param>
    /// <param name="autoCloseFtpClient">
    ///     自动关闭FTP客户端 默认自动关闭客户端连接
    ///     如果为false需要自行调用 CloseFtpClientConnectAsync()方法
    /// </param>
    public GetFtpFileStreamConfig(string rootDirectory, string fileGroupName, string fileRelativePath,
        AsyncFtpClient ftpClient, bool autoCloseFtpClient) : base(rootDirectory, fileGroupName, fileRelativePath)
    {
        ArgumentNullException.ThrowIfNull(ftpClient, nameof(ftpClient));
        FtpClient = ftpClient;
        AutoCloseFtpClient = autoCloseFtpClient;
    }

    /// <summary>
    ///     FTP客户端
    /// </summary>
    public AsyncFtpClient FtpClient { get; }

    /// <summary>
    ///     自动关闭FTP客户端
    /// </summary>
    public bool AutoCloseFtpClient { get; }
}